package com.qf.smsplatform.strategy.api;


import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Set;

@FeignClient(value = "SMS-PLATFORM-CACHE")
public interface CacheService {



    @RequestMapping(value = "/cache/hget/{key}/{field}", method = RequestMethod.GET)
     String hGet(@PathVariable("key") String key, @PathVariable("field") String field);

    /**
     * 获取key-value结构, String类型
     * @param key  String类型
     * @return
     */
    @RequestMapping(value = "/cache/get/{key}", method = RequestMethod.GET)
    String get(@PathVariable("key") String key);



    /**
     * 添加数据到set结构柱中
     * @param key
     * @param value
     * @return
     */
    @RequestMapping(value = "/cache/sadd")
    boolean sadd(@RequestParam("key") String key, @RequestParam("value") String... value);

    /**
     * set集合的交集操作
     * @param key
     * @param otherValue
     * @return
     */
    @RequestMapping(value = "/cache/inter")
    Set<Object> intersect(@RequestParam("key")String key, @RequestParam("otherValue") String otherValue);

    /**
     * 获取set集合数据
     * @param key
     * @return
     */
    @RequestMapping(value = "/cache/members/{key}",method = RequestMethod.GET)
    Set<String> members(@PathVariable(value = "key") String key);



    /**
     * 根据分数范围获取zset中的数据
     *
     */
    @RequestMapping(value = "/cache/zrangebyscore",method = RequestMethod.GET)

   Set<Object> zRangeByscore(@RequestParam(value = "key")String key,@RequestParam(value = "min") Double min,@RequestParam(value = "max")Double max);

    @RequestMapping(value = "/cache/keys/{pattern}")
    Set<String> keys(@RequestParam(value = "pattern") String pattern);

    @RequestMapping(value = "/cache/hmget/{key}", method = RequestMethod.GET)
   Map hMGet(@PathVariable("key") String key);


    //hincr
    @RequestMapping(value = "/cache/hincr")

   Long hincr(@RequestParam String key,@RequestParam String field,@RequestParam  Long delta );




    @RequestMapping(value = "/cache/incr", method = RequestMethod.GET)
   Long incr(@RequestParam("key") String key, @RequestParam("delta") long delta);

}
